package io.scnb.lesson001.demo3;

/**
 * spring容器启动的时候会自动调用UserStaticFactory中的buildUser1静态方法获取UserModel对象，将其作为beans.xml中
 * createBeanByStaticFactoryMethod1名称对应的bean对象放在spring容器中
 * 会调用UserStaticFactory中的buildUser2静态方法获取UserModel对象，将其作为beans.xml中
 *  createBeanByStaticFactoryMethod2名称对应的bean对象放在spring容器中
 */
public class UserStaticFactory {

    /**
     * 静态无参方法创建UserModel
     */
    public static UserModel buildUser1() {
        System.out.println(UserStaticFactory.class + ".buildUser1()");

        UserModel userModel = new UserModel();
        userModel.setName("我是无参静态构造方法创建的");
        return userModel;
    }

    /**
     * 静态有参方法创建UserModel
     */
    public static UserModel buildUser2(String name, int age) {
        System.out.println(UserStaticFactory.class + ".buildUser2()");

        UserModel userModel = new UserModel();
        userModel.setName(name);
        userModel.setAge(age);
        return userModel;
    }
}
